home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swaga_c.zip / CMDLINE.SWG / 0006_Kill Underscore.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  54 lines

  1. {
  2. This is another BAsm I've written to optimize my Program. Some of the
  3. comma-delimited fields have the Underscore Character in the place of Spaces. It
  4. is desirable For them to be replaced For use in my Program.
  5.  
  6. BeFore writing this Procedure I was using:
  7.  
  8. Procedure Kill_(Var Strng : String);
  9. Repeat
  10.   Subpos := Pos('_',String);
  11.   if subpos > 0
  12.      then Strng[subpos] := ' ';
  13. Until Killpos Subpos = 0;
  14. end;
  15.  
  16. This was getting called approx 250,000 times in my project, and Turbo ProFiler
  17. practically waved a red flag at me about it!  <grin>
  18.  
  19. This is my new Procedure which screams as Compared to the previous routine.
  20.  
  21. I am using TP 6.0 Professional.
  22.  
  23. -------------  Code Snippet begins  --------------
  24. }
  25. Procedure KILL_(Var STRNG); Assembler;
  26. { This Procedure KILLS Underscores from a String _and MODifIES THE orIGinAL_ }
  27. Asm
  28.   LES DI, STRNG
  29.   xor CX, CX
  30.   MOV CL, [ES:DI] { Get String Length}
  31.   MOV AL, '_'
  32.   inC DI  { Point to FIRST String Char }
  33.   CLD
  34. @Scan_For_underscore_loop:
  35.   SCASB
  36.   JE @FOUND_UNDERSCorE
  37.   LOOP @SCAN_For_UNDERSCorE_LOOP
  38.   JMP @OUTTATHIS
  39. @FOUND_UNDERSCorE:
  40.   DEC DI
  41.   MOV Byte PTR [ES:DI], ' '
  42.   inc di
  43.   jmp @scan_For_underscore_loop
  44. (92 min left), (H)elp, More? @OUTTATHIS:
  45. end;
  46.  
  47. {
  48. Does anyone more knowledgable in Assembly than I am have any suggestions For
  49. this Procedure?   I Realize I am working With the original copy of the String
  50. with this Procedure, and modifying it to boot, but I am saving the time to copy
  51. it to/from the stack when I am making the changes.    My Program doES take this
  52. into account, and ONLY passes Strings to the procedure.
  53. }
  54.